<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%   String path = request.getContextPath();   
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
	String bpath = request.getScheme()+"://"+request.getServerName();
%>
<!DOCTYPE html>
<html lang="en">
 <head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0,,user-scalable=no">
 <meta name="description" content="">
 <meta name="author" content="">
 <link rel="icon" href="http://v3.bootcss.com/favicon.ico">
<title>新增照片</title>
 <link href="/bootstrapDemo/bootstrap/css/bootstrap.css" rel="stylesheet">
 <link href="/bootstrapDemo/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
 <script src="/bootstrapDemo/js/jquery.js"></script>
<script src="/bootstrapDemo/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
function toSubmitPo(){
	 var reg = /^\d+$/;
	var PTitle = document.getElementById("PTitle").value;
	var PDesc = document.getElementById("PDesc").value;
	var POrder = document.getElementById("POrder").value;
	if(PTitle==null || PTitle=="" || PTitle=="undefined"){
		alert("请输入照片描述！");
		return;
	}else if(PDesc==null || PDesc=="" || PDesc=="undefined"){
		alert("请选择照片！");
		return;
	}else if(POrder==null || POrder=="" || POrder=="undefined"){
		alert("请输入相册序号！");
		return;
	}else if(!POrder.match(reg)){
		alert("相册序号为数字");
	}else{
		document.getElementById("photoadd").submit();
	}
}

var isIE = /msie/i.test(navigator.userAgent) && !window.opera;         
function fileChange(target) {     
  var fileSize = 0;          
  if (isIE && !target.files) {      
    var filePath = target.value;      
    var fileSystem = new ActiveXObject("Scripting.FileSystemObject");         
    var file = fileSystem.GetFile (filePath);      
    fileSize = file.Size;     
  } else {     
   fileSize = target.files[0].size;      
   }    
   var size = fileSize / 1024;     
   if(size>200){   
    alert("附件不能大于200kb");
    document.getElementById("subBut").style.display="none";
   }else{
	   document.getElementById("subBut").style.display="";
   }   
}
</script>
</head>
<body>
<ol class="breadcrumb">
  <li><a href="#">相册管理</a></li>
  <li class="active">新增照片</li>
</ol>
<center>
	<div class="panel-body" style="width: 95%;"><b>${photo.TPhotoGroup.GName }</b>
	<form id="photoadd"  name = "photoadd" action="/photo/savePhoto.action" method="post" enctype="multipart/form-data">
	  <table class="table">
	 	 <tr style="background-color: white;border: 0">
				<td width="10%">照片描述</td>		
				<td >
				<input type="hidden" name="photo.TPhotoGroup.id"  value="${photo.TPhotoGroup.id }"/>
				<input type="text" name="photo.PTitle"  class="form-control" id="PTitle" placeholder="请填写照片描述">
				</td>		
		</tr>
		<tr style="background-color: white;border: 0">
			<td >照片序号</td>		
			<td >
				<input type="number" name="photo.POrder"  class="form-control" id="POrder" >
			</td>		
		</tr>
		<tr style="background-color: white;border: 0">
			<td >上传照片</td>		
			<td >
			<input type="file" name="uploadfile" id="PDesc" onchange="fileChange(this)">
			</td>		
		</tr>
	  </table>
	  <button type="button" class="btn btn-primary" id="subBut" onclick="toSubmitPo();">提交</button>
	  <button  type="button" class="btn btn-primary"  onclick="resetForm();">重置</button>
	  </form>
	</div>
</center>

</body>
</html>